'''最简单的穷举'''
""" def qj(min, max):
    for b in range(1, 5):
        for s in range(1, 5):
            for g in range(1, 5):
                if b != s and b != g and s != g:
                    print("{0}{1}{2}".format(b, s, g))


qj(1, 5) """
'''反复插入'''
import copy


def insert_to_list(ls, ch):  #返回在一个一维数组中插入一个数的所有排列可能性
    newls = []
    for i in range(0, len(ls) + 1):
        temp = copy.copy(ls)
        temp.insert(i, ch)
        newls.append(temp)
    return newls


def Combination(ls):  #排列组合
    newls = [[]]
    for ch in ls:
        temp = []
        for ls in newls:
            temp += insert_to_list(ls, ch)
        newls = []
        newls = copy.deepcopy(temp)
    return newls


ls = [1, 2, 3, 4]
ch = 4
newls = Combination(ls)
print(newls)